/**
 * Created by 15c on 2017/11/29.
 */
//获取页面跳转传过来的参数值
function request(params) {

    var url = location.href;

    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");

    var paraObj = {};

    for (i = 0; j = paraString[i]; i++) {

        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);

    }

    var returnValue = paraObj[params.toLowerCase()];

    if (typeof (returnValue) == "undefined") {

        return "";

    } else {

        return returnValue;

    }

}
//编写游记用户的userId
var userId;
var url = 'http://www.xiaowenxiong.cn/test';
//服务器图片路径
var imgUrl = url + "/resources/img/";
//展示用户信息
function showUser(userId) {

    $.ajax({
        type: 'GET',
        url: url + '/users/details/show',
        data: {
            userId: userId
        },
        dataType: 'json',
        timeout: 50000,
        success: function (result) {
            var data = result.data;
            if (result.error == 0) {
                console.log(data);
                if (data.hasOwnProperty("userAvatarAddress") && data.userAvatarAddress.length != 0) {
                    $("#user_avt").attr('src', 'http://www.xiaowenxiong.cn/test/resources/img/'+data.userAvatarAddress);
                }
                $("#user_email").text(data.userEmail);

            } else if (result.error == 106) {
                alert("信息查询出错");
            }
        },
        error: function (xhr, type) {
            alert('请求出错，再刷新试试');
        }
    });
}

$(document).ready(function () {
    userId=window.sessionStorage.getItem(loginUserId);
    showUser(userId);

});